home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Scripts / FileMakerPro.vu < prev    next >
Encoding:
Text File  |  1993-12-17  |  12.0 KB  |  339 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        FileMakerPro.vu
  5. #
  6. #    Contains:    Quick look test script for FileMaker Pro version 2.0
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #     <1.0.6>     12/8/93    KTA        Check to insure dialog is present before attempting to add
  19. #                                    fields.
  20. #     <1.0.5>     9/30/93    KTA        Initialize gFileName prior to gApptitle being updated by
  21. #                                    launchTwitch().
  22. #     <1.0.2>     6/16/93    NAGA        Renaming InitGlobals(ScriptLevel)to InitGlobals(ScriptLevel)
  23. #        <1+>     5/25/93    NAGA        Adding header and porting old files to follow new standards
  24. #
  25. # ****************************************************************************
  26. #
  27.  
  28.  
  29. ########################################################################
  30. #                            External libraries 
  31. #=======================================================================
  32. Libraries "Output.Lib", "DoTasks.Lib","Draw.Lib", "StandardFile.Lib", "DA.Lib", "Font.Lib", "UserInterface.Lib", "Globals.Lib", "LaunchQuit.Lib", "TCS.Lib";
  33.  
  34.  
  35. #########################################################################
  36. ###            Application Specific Tasks
  37. #########################################################################
  38.  
  39. #########################################################################
  40. #                        InitAppGlobals()
  41. #========================================================================
  42. # Author:        ML
  43. # Description:    Sets up the tool palettes for Filemaker Pro.  This task
  44. #                must be called first.
  45. # Parameters:    None
  46. # Returns:        Nothing
  47. # Examples:        InitAppGlobals()
  48. #========================================================================
  49. # History:
  50. #
  51. ########################################################################
  52. task InitAppGlobals()
  53. begin
  54.     
  55.     logstr("setting up {global gApptitle}'s tool globals");            
  56.     global kClick, kDrag, kMultiDrag, kMultiClickDrag, kMultiClick;
  57.     global kPalDocWind, kPalWind, kPullOffPal, kPopUpPal, kScrollPal;
  58.     global kDrawPaletteNum := 1; 
  59.     
  60.     global gPaletteList :=    {
  61.                             {                    #### Start Palette #1 - Draw
  62.                             {6,152,64,184,0},    # Location of tab palette relative to the window
  63.                             kPalDocWind,        # Palette type
  64.                             {3,2},                # Size of Tool matrix {numElemsWide,numElemsTall}
  65.                             {19,16},            # Offset between tools {h,v}
  66.                             0,                    # Not used at this time
  67.                             0                    # Not used at this time
  68.                             }                    #### End Palette #1
  69.     };
  70.  
  71.     ### Palette Elements:=        Tool#, Pal#,     ToolName,     ToolType,    DblClktoEnd        SetAttributes
  72.     global SelectTool :=         { 1,      1,        "Select",        kClick,    0,                {0}                };
  73.     global TextTool :=             { 2,      1,        "Text",            kClick, 0,                {0}                };
  74.     global LineTool :=             { 3,      1,        "Line",            kDrag,    0,                {0}                };
  75.     global RectangleTool :=     { 4,     1,        "Rectangle",    kDrag,    0,                {0}                };
  76.     global RoundRectTool :=        { 5,      1,        "Round Rect",    kDrag,    0,                {0}                };
  77.     global CircleTool :=         { 6,     1,        "Circle",        kDrag,     0,                {0}                };
  78.     
  79.     global DrawToolList:={    LineTool,
  80.                             RectangleTool,
  81.                             RoundRectTool, 
  82.                             CircleTool
  83.                         };    # don't include select tool because may move a field
  84.                             # don't include text tool because double click required
  85.                             # to choose next tool
  86.     global gToolList:= DrawToolList;
  87.     global gWindowInset := {73,42,20,50};
  88.     global gBoundingRect:= {0,0,511,341};
  89.  
  90.     logstr("Initializing font globals for '{global gApptitle}'");
  91.     
  92.         ### font characteristic lists
  93.     global gFontSizeList := {'6','8','9','10','12','14','18','24','36','48','72'};
  94.     global gFontStyleList := {'Bold','Italic','Underline','Outline','Shadow','Condensed','Extended'};
  95.     
  96.         ### Name of the Plain (style) menu item  ####
  97.     global gPlainStyle := "Plain Text";            # Plain-Style menu item
  98.  
  99.         ### How to get to the next line
  100.     global gNextLineMethod := 1;            
  101.         ### 1 - ReturnKey,  2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
  102.     
  103.         ### Does moving to the next line clear all font info
  104.     global gNextLineClearsFontSettings := 0;
  105.     
  106. end;    #InitAppGlobals
  107.  
  108. ################################################################################
  109. # Name:    Views()        Author: KTA (x45604)
  110. # Description:        Select the Keyboard eq specified-This is to change views.
  111. # Applications:        Implemented for each app.
  112. ################################################################################    
  113. task Views() begin
  114.     LogStr( "Changing Views",3);
  115.     selectMenuItem("Preview", "Select");
  116.     selectMenuItem("Layout", "Select");
  117. end;
  118.  
  119.  
  120. #########################################################################
  121. #                            NewField(FieldName, FieldType)
  122. #========================================================================
  123. # Author:        KTA
  124. # Description:    Adds field to FileMaker's 'Field Definition' Dialog 
  125. # Parameters:    FieldName - Name of Field
  126. #                FieldType - Type of Field
  127. # Returns:        Nothing
  128. # Examples:        NewField();
  129. # Assumptions:    None 
  130. #========================================================================
  131. # History:
  132. #
  133. #########################################################################
  134. task NewField(FieldName,FieldType) begin
  135.     IsRadioButton := Match [radioButton t:FieldType w:[window o:1]];
  136.     if (IsRadioButton) 
  137.     begin
  138.         select IsRadioButton;
  139.         type k:{FieldName};
  140.     #str:= "Typed '{FieldName}' and selected the '{FieldType}' RadioButton";
  141.         LogStr("Typed '{FieldName}' and selected the '{FieldType}' RadioButton");
  142.         SpecialKey(returnKey, 'Return Key');
  143.     end;
  144.     else begin
  145.         str := ("There was no match for a RadioButton named '{FieldType}'");
  146.         LogStr(str);
  147.     end;
  148. end;
  149.  
  150.  
  151. #########################################################################
  152. #                            CreateDataBase()
  153. #========================================================================
  154. # Author:        KTA
  155. # Description:    Creates a FileMaker DateBase
  156. # Parameters:    None
  157. # Returns:        Nothing
  158. # Examples:        CreateDataBase();
  159. # Assumptions:    None 
  160. #========================================================================
  161. # History:
  162. #
  163. #########################################################################
  164. task CreateDataBase() begin
  165.     Println "###### Add some Database Fields ######";
  166.     wait(2);
  167.     if not(match [window o:1 s:dialog]!)
  168.         selectMenuItem(12,4);                # help to insure dialog where you define fields is present.
  169.     NewField('Name','Text');                    # 1st Parameter is FieldName 
  170.     NewField('Address','Text');                    # 2nd Parameter is FieldType
  171.     NewField('City','Text');
  172.     NewField('State','Text');
  173.     NewField('Zip','Text');
  174.     NewField('Phone','Number');
  175.     NewField('Birth Date','Date');
  176.     NewField('Portrait','Picture');
  177.     
  178.     selectButton('Done');
  179.     
  180.     LogStr("Created a new database",3);
  181. end;
  182.  
  183. #########################################################################
  184. #                            EnterData()
  185. #========================================================================
  186. # Author:        KTA
  187. # Description:    Enters Data into FileMaker DateBase
  188. # Parameters:    NumTimes - Number of time through.
  189. # Returns:        Nothing
  190. # Examples:        EnterData();
  191. # Assumptions:    None 
  192. #========================================================================
  193. # History:
  194. #
  195. #########################################################################
  196. task EnterData(NumTimes) begin
  197.  
  198.     Println "###### Enter some Data ######";
  199.     whichScrapItem := 0;
  200.     SpecialKey(tabKey, 'tab Key');
  201.     
  202.     for count := 1 to NumTimes 
  203.     begin
  204.     
  205.         JohnList := {'John Doe','25 Main St.','San Francisco','CA','95168','657-9876','10-14-58'};
  206.         CalvinList := {'Calvin Hobbes','15680 Beach Blvd.','Santa Cruz','CA','95647','756-6453','03-17-61'};
  207.         WillList := {'Will Clark','1280 Broadway ','Candlestick','CA','95637','213-7645','02-11-65'};
  208.         BruceList:= {'Bruce Wayne', '110 First St','Gotham City', 'NJ', '952145', '(423) 456-4675', '09-05-66'};
  209.  
  210.         DataList :={JohnList, CalvinList, WillList, BruceList};
  211.         numrecords := card(DataList);
  212.         
  213.         for each DataItem in DataList 
  214.         begin
  215.  
  216.             TypeList( DataItem, 2, 1 );        #Type all of the DataItems and a TabKey
  217.             
  218.             ####### Different item in Scrap for each DataItem ######
  219.             whichScrapItem := whichScrapItem + 1;
  220.             if (whichScrapItem > 7)                 # There are 7 items in Default 7.0 Scrapbook
  221.                 whichScrapItem := 1;
  222.  
  223.             ScrapBook( whichScrapItem );
  224.             if (whichScrapItem = 1)
  225.                 LogStr("Note: Error expected if attempting to paste text.  FileMaker does not accept TEXT in the PICT Field",2);
  226.             
  227.             DialogCheck();
  228.             selectMenuItem("New Record", "Edit");
  229.  
  230.         end; # for each DataItem in DataList
  231.         
  232.         LogStr("Entered {numrecords} records",3);
  233.         
  234.     end; # for count := 1 to NumTimes 
  235.     
  236. end;
  237.  
  238. #########################################################################
  239. #                            EnlargePICTField()
  240. #========================================================================
  241. # Author:        KTA
  242. # Description:    Enlarges the PICT field for this script in the Layout view
  243. # Parameters:    Nothing
  244. # Returns:        Nothing
  245. # Examples:        EnlargePICTField();
  246. # Assumptions:    None 
  247. #========================================================================
  248. # History:
  249. #
  250. #########################################################################
  251. task EnlargePICTField() begin    
  252.     temp := MouseSpeed(5);
  253.     MoveRelativetoWindow(353,185);        #This is used to draw a larger pict box
  254.     click;                                #in the layout window
  255.     wait(2);
  256.     MoveMouse(130, 80, 0, 1);
  257.     MouseSpeed(Temp);
  258. end;
  259.  
  260. #########################################################################
  261. #                            FMProSetupDoText()
  262. #========================================================================
  263. # Author:        ML
  264. # Description:    Initializes FM tool globals
  265. # Parameters:    nada
  266. # Returns:        Nothing
  267. # Examples:        FMProSetupDoText();
  268. # Assumptions:    None 
  269. # Applications:    FM Pro
  270. #========================================================================
  271. # History:
  272. #
  273. #########################################################################
  274. task FMProSetupDoText()
  275. begin
  276.     Draw(TextTool);
  277. end;
  278.  
  279.  
  280. ################################################################################
  281. ####################             Main Script                    ####################
  282. ################################################################################
  283. script FilemakerPro (ScriptLevel:= -1)
  284. begin
  285.     InitGlobals(ScriptLevel);
  286.     InitDraw();
  287.     InitFonts();
  288.     global gAppTitle := 'Filemaker Pro';
  289.     global gAppVersion := '2';        # version of app you will be running
  290.     global gFileName := "@!@-{gBuildVers}-{gAppTitle}";    #This is used in SaveAs when saving files
  291.     SuiteStart('FileMakerPro.vu');                    # begin a new test suite
  292.     if LaunchTwitch("{gAppTitle}",gAliasDirectory) # launch or twitch to your app
  293.     begin
  294.         global gSetupDoText := task FMProSetupDoText;
  295.         InitAppGlobals();
  296.         (*
  297.         *)    
  298.         DoSetUpApp('Cancel',-1,,,,,0);            # select "Cancel" at launch
  299.         
  300.         SaveAs(gFileName);                        # name database
  301.         
  302.         CreateDataBase();                        # Create
  303.     
  304.         CloseWindow();                            # close window
  305.         OpenFile(gLastSavedFile);                # SF_Get will open file 
  306.         
  307.         selectMenuItem("Layout", "Select");        # Modify default layout
  308.         
  309.         EnlargePICTField();                        # Enlarge the PICT Box
  310.                                         
  311.         DoDraw();                                # Test Draw Tools
  312.         
  313.         DoText();                                # Test Text
  314.         
  315.         selectMenuItem("Browse", "Select");        # Browse Mode
  316.             
  317.         DoWindow();                                # test windows
  318.         
  319.         EnterData(1);                            # Enter Some Data
  320.             
  321.         Views();                                # change views
  322.             
  323.         selectMenuItem("Save A Copy As", "File");    # To Select Save As from the File menu
  324.         selectButton('Cancel');                        # Cancel the Standard SF_Put Dialog
  325.         
  326.         selectMenuItem("Save A Copy As", "File");    # To Select Save As from the File menu
  327.         SaveAs(gFileName,0);                        # To test SF_Put
  328.         
  329.         DoCloseApp(-1);                                # no save/replace/modify
  330.  
  331.         LogStr("############################# LIMITATIONS: ############################");
  332.         LogStr("NOTE: Scrapbook calls are handled in the EnterData() task");
  333.         LogStr("NOTE: FileMaker Saves Automatically so there is no Save or Revert");
  334.         LogStr("NOTE: Error expected if attempting to paste text.  FileMaker does not accept TEXT in the PICT Field",2);
  335.  
  336.     end; # if LaunchTwitch("{gAppTitle}",gAliasDirectory)
  337.     SuiteEnd();
  338. end;
  339.